package com.wenjie.original.entity;

import com.mybatisflex.annotation.EnumValue;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import com.wenjie.common.enumHandler.IEnum;
import com.wenjie.original.entity.common.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

import java.util.Arrays;

@Data
@Table("sys_log_login")
@ApiModel("登录日志表 ")
public class SysLogLogin extends BaseEntity {

    @Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
    @ApiModelProperty("序号")
    private Long sysInfoId;

    @ApiModelProperty("用户ID")
    private Long sysAdminId;

    @ApiModelProperty("手机号")
    private String tel;

    @ApiModelProperty("姓名")
    private String name;

    @ApiModelProperty("登录状态 0成功 1失败")
    private STATUS status;

    @ApiModelProperty("登录IP地址")
    private String ipaddr;

    @ApiModelProperty("登录地点")
    private String loginLocation;

    @ApiModelProperty("经度")
    private String lng;

    @ApiModelProperty("维度")
    private String lat;

    @Getter
    @AllArgsConstructor
    public enum STATUS implements IEnum<Integer> {
        arg0(0, "成功"), arg1(1, "失败");

        @EnumValue
        private Integer code;
        private String message;

        /**
         * @Description 通过code进行查询枚举值
         * @author wenjie
         * @date 2024/5/30 15:21
         */
        public static STATUS getBycode(Integer code) {
            return Arrays.stream(STATUS.values()).filter(s -> s.getCode().equals(code)).findFirst().orElse(null);
        }
    }


}
